import React from 'react';
import '../static/PcLogin.scss';
import { Link } from 'react-router-dom'
import { connect } from 'react-redux';
import { bindActionCreators } from 'redux';
import * as homeActions from '../actions/home';
/**
 * PC登录
 */
class PcLogin extends React.Component {

    constructor(props){
        super(props);
        this.state = {
            phone:'',
            password:''
        }
    }

    onChange = ()=>{

    }
    onClick = ()=>{
        this.props.actions.login(this.state);
    }

    onChange = (event)=>{
        if(event.target.name == 'phone'){
            this.setState({
                'phone':event.target.value
            })
        }
        if(event.target.name == 'password'){
            this.setState({
                'password':event.target.value
            })
        }
    }
    render() {
        return (
            <div className="PcLogin">
                 <div className="main">
                    <div className="inputT1">
                        <label>
                            <i className="fa fa-user-o" aria-hidden="true"></i>
                            <input type="text" name="phone" onChange={this.onChange} placeholder="请输入登录账号"/>
                        </label>
                    </div>
                    <div className="inputT2">
                        <label>
                            <i className="fa fa-key" aria-hidden="true"></i>
                            <input type="password" name="password" onChange={this.onChange} placeholder="请输入登录密码"/>
                        </label>
                    </div>
                    <div className="loginBtn" onClick={this.onClick}>登录</div>
                    <Link to={'/Register'}>
                        <div className="loginBtn registerBtn">注册</div>
                    </Link>
                </div>
            </div>
        )
    }
}

const mapStateToProps = (state) => ({
    demo: state.data.demo,
});

const mapDispatchToProps = (dispatch) => {
  return {
    actions:bindActionCreators(homeActions, dispatch)
  };
};

export default connect(mapStateToProps, mapDispatchToProps)(PcLogin);